package cn.iocoder.yudao.module.security.dal.dataobject.whitelistevent;

import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.*;

import java.io.Serializable;
import java.time.Instant;
import java.time.LocalDateTime;
import java.util.List;

/**
 * 白名单事件 DO
 *
 * @author cai
 */

@Data
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class WhitelistEventEsDO implements Serializable {

    // ES元数据字段
    private String _index;

    @JSONField(name = "_id")
    private String id;
    private Double _score;

    @JSONField(name = "_source")
    private SourceData source;

    // 嵌套数据结构（静态内部类模式）
    @Data
    public static class SourceData {

        @JSONField(name = "@timestamp")
        private String timestamp;

        private Agent agent;
        private Log log;
        private Endpoint destination;
        private Rule rule;
        private Endpoint source;
        private Vulnerability vulnerability;
        private String type;
        private Network network;
        private List<String> tags;
        private Service service;
        private DataStream dataStream;

        // 嵌套类定义
        @Data
        public static class Agent {
            private String type;
            // getters/setters
        }

        @Data
        public static class Log {
            @JsonProperty("syslog")
            private Syslog syslog;

            public static class Syslog {
                private Severity severity;
                private String hostname;
                private String appname;
                private Integer priority;
                private Facility facility;

                public static class Severity {
                    private int code;
                    private String name;
                }

                public static class Facility {
                    private int code;
                    private String name;
                }
            }
        }

        @Data
        public static class Endpoint {
            private String port;  // 保留字符串类型处理非常规值
            private String ip;
        }

        @Data
        public static class Rule {
            private String reference;
            private String version;
            private String uuid;
        }

        @Data
        public static class Vulnerability {
            private String severity;
            private String description;
            private String classification;
        }

        @Data
        public static class Network {
             private String code1;
             private String code2;
             private String code3;
             private String code4;
            private String app;
            private String func;
            @JSONField(name = "func_cn") private String funcCn;
            private String transport;
            @JSONField(name = "msg_type") private String msgType;
            @JSONField(name = "register_area") private String registerArea;
            @JSONField(name = "db_area") private String dbArea;
            @JSONField(name = "point_type") private String pointType;
            @JSONField(name = "object_group_num") private String objectGroupNum;
            @JSONField(name = "variant_num") private String variantNum;
            @JSONField(name = "main_info") private String mainInfo;
            // 其他字段...
        }

        @Data
        public static class Service {
            private String type;
        }

        @Data
        public static class DataStream {
            private String namespace;
            private String type;
        }
    }

}